home *** CD-ROM | disk | FTP | other *** search
- /*
- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
- ▒ ▒
- ▒ ▒
- ▒ Neuromancer's Graphics Library ▒
- ▒ Version 1.0c ▒
- ▒ ▒
- ▒ This program illustrates yet another method for ▒
- ▒ animation. In this case, dirtied rectangles ▒
- ▒ are flipped to the active pages. This is more ▒
- ▒ elaborate but the effect is much smoother. ▒
- ▒ Alternatively, to avoid doing dirty rectangles ▒
- ▒ technique when transferring to the video memory, ▒
- ▒ copy the entire page (PAGE_1) to the video buffer. ▒
- ▒ ▒
- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
- ▒ ▒
- ▒ Project: MTLIB01.LIB ▒
- ▒ DEMO8.CPP ▒
- ▒ ▒
- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
- */
-
- #include <iostream.h>
- #include <stdlib.h>
- #include <conio.h>
- #include "video.h"
- #include <dos.h>
- #include "bitmap.h"
-
- byte sprite1[]={
- /*23,29,*/
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,42,42,42,42,42, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,42,42,42,42,42,42,42,42,42, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0,42,42,42,42,42,42,42,42,42,42,42, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,42,42,42,42,42,42,42,42,42,42,42,42,42, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,42,42,42,42,42,42,42,42,42,42,42,42,42, 0, 0, 0, 0, 0,
- 0, 0, 0, 0,42,42,42,42,42,42,42,42,42,42,42,42,42,12,40, 0, 0, 0, 0,
- 0, 0, 0, 0,42,42,42,42,42,42,42,42,42,42,42,42,42,41,40, 0, 0, 0, 0,
- 0, 0, 0, 0,42,42,42,42,42,42,42,42,42,42,42,42,42,40,40, 0, 0, 0, 0,
- 0, 0, 0, 0,42,42,42,42,42,42,42,42,42,42,42,42,42,40,40, 0, 0, 0, 0,
- 0, 0, 0, 0,42,42,42,42,42,42,42,42,42,42,42,42,42,40,40, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,42,42,42,42,42,42,42,42,42,42,42,12,40, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0,41,42,42,42,42,42,42,42,42,42,42,40,40, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0,41,42,42,42,42,42,42,42,42,40,40, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0,41,41,42,42,42,42,12,40,40, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,41,41,41,41,41, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,30,29,27,25,24, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,30,29,27,25,24, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0,46,45, 0, 0, 0, 0, 0, 0,30,29,27,25,24, 0, 0, 0, 0, 0, 0,46,44, 0,
- 0,46,45, 0, 0, 0, 0, 0, 0,30,29,27,25,24, 0, 0, 0, 0, 0, 0,46,44, 0,
- 0,46,45, 0, 0, 0, 0, 0,29,30,29,27,25,24,26, 0, 0, 0, 0, 0,46,44, 0,
- 0,46,45,44, 0, 0, 0,29,29,30,29,27,25,24,26,26, 0, 0, 0,46,46,44, 0,
- 0,46,45,44, 0, 0,29,29,29,30,29,27,25,24,26,26,26, 0, 0,46,46,44, 0,
- 0,46,45,44, 0,29,29,29,29,30,29,27,25,24,26,26,26,26, 0,46,46,44, 0,
- 0,46,45,44,29,29,29,29,29,30,29,27,25,24,25,26,26,26,26,46,46,44, 0,
- 0,46,45,44,29,29,29,29,29,30,29,27,25,24,25,25,25,26,26,46,46,44, 0,
- 0,46,45,44,29,29,29, 0, 0,30,29,27,25,24, 0, 0,25,25,26,46,46,44, 0,
- 0,46,45,44,29,29, 0, 0, 0,23,23,24,24,23, 0, 0, 0,25,25,46,46,44, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- };
-
- byte sprite2[] = {
- /*20,20,*/
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 75, 75,
- 75, 75, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
-
- };
-
- byte sprite3[]={
- //20,20
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
- };
-
- byte sprite4[]={
- //20,20
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
- };
-
-
- byte sprite5[]={
- //20,20
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
- };
-
- block page1,page2;
-
- void main(void)
- {
-
- int xcor;
- int ycor;
-
- int xcor1;
- int ycor1;
-
- int xdir;
- int ydir;
-
- int xdir1;
- int ydir1;
-
- int flag=0;
- int inc=0;
-
- mtSetVGAMode(); //Set up VGA Mode
- mtClrScr(25);
-
-
- if ((page1=mtAllocPage(0,0,319,199))==NULL)
- {
- mtSetTextMode();
- cout << "Error setting up Page1"<<endl;
- exit(0);
- }
-
- if ((page2=mtAllocPage(0,0,319,199))==NULL)
- {
- mtFreePage(PAGE_1);
- mtSetTextMode();
- cout << "Error setting up Page2"<<endl;
- exit(0);
- }
-
- //typically, this is the hidden screen where you would download
- //your static background
- mtSetPage(PAGE_1);
- mtClrScr(25);
-
- mtSetPage(PAGE_2);
- mtClrScr(25);
-
- xcor = random(297);
- ycor = 150;
- xcor1 =random(300);
- ycor1 =30;
-
- xdir =5;
- ydir =5;
- xdir1=5;
- ydir1=5;
- flag=0;
- inc=0;
-
- mtSetPage(PAGE_1);
-
- while(!kbhit())
- {
-
- xcor += xdir;
- xcor1 += xdir1;
-
- if (xcor < 0 || xcor > 297 ) {
- xdir = -xdir;
- xcor += xdir;
- }
-
- if (xcor1<0||xcor1 >300) {
- xdir1 = -xdir1;
- xcor1 += xdir1;
- }
-
- mtCPutBlit(xcor, ycor, 23, 29, sprite1); //copy mode
- if (flag ==0){
- mtCPutSprite(xcor1, ycor1, 20, 20, sprite2); //sprite mode
- inc++;
- if (inc == 1) flag = 1;
- }
- else
- if (flag==1)
- {
- mtCPutSprite(xcor1, ycor1, 20, 20, sprite4); //sprite mode
- inc++;
- if (inc==2) flag=2;
- }
- else
- if (flag==2)
- {
- mtCPutSprite(xcor1, ycor1, 20, 20, sprite3); //sprite mode
- inc++;
- if (inc==3) flag=3;
- }
- else
- if (flag==3)
- {
- mtCPutSprite(xcor1, ycor1, 20, 20, sprite5); //sprite mode
- inc++;
- if (inc==4)
- {
- flag=0;
- inc=0;
- }
- }
- mtWaitRetrace();
-
- //using dirtied rectangles
- mtCopyBlk(xcor-5,ycor-5,xcor+28, ycor+34, xcor-5,ycor-5,PAGE_1,PAGE_0);
- mtCopyBlk(xcor1-5,ycor1-5,xcor1+25,ycor1+25,xcor1-5,ycor1-5,PAGE_1,PAGE_0);
-
- mtCopyBlk(xcor,ycor,xcor+23, ycor+29, xcor,ycor,PAGE_2,PAGE_1);
- mtCopyBlk(xcor1,ycor1,xcor1+20,ycor1+20,xcor1,ycor1,PAGE_2,PAGE_1);
- }
-
- getch();
-
- mtFreePage(PAGE_1);
- mtFreePage(PAGE_2);
-
- mtSetTextMode();
-
- cout << "Thank you for using the library!" << endl;
-
- exit(0);
-
- }
-
-
-
-
-
-
-
-